package com.ruoyi.special.constant;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.ruoyi.special.model.vo.CondiChildInfoVO;
import com.ruoyi.special.model.vo.CondiInfoVO;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class CondiConstant {

    public static List<CondiInfoVO> dataList = new ArrayList<>();

    public static CondiInfoVO notPush = new CondiInfoVO("不推送", "notPushDayWeek", Arrays.asList(
            new CondiChildInfoVO("周一","1"),
            new CondiChildInfoVO("周二","2"),
            new CondiChildInfoVO("周三","3"),
            new CondiChildInfoVO("周四","4"),
            new CondiChildInfoVO("周五","5"),
            new CondiChildInfoVO("周六","6"),
            new CondiChildInfoVO("周日","7")
    ));

    public static CondiInfoVO zhima = new CondiInfoVO("芝麻分", "zhima", Arrays.asList(
            new CondiChildInfoVO("700分以上","zm005"),
            new CondiChildInfoVO("650-700分","zm004"),
            new CondiChildInfoVO("600-650分","zm003"),
            new CondiChildInfoVO("1-600分","zm002"),
            new CondiChildInfoVO("无","zm001")
    ));

    public static CondiInfoVO huabei = new CondiInfoVO("支付宝花呗", "huabei", Arrays.asList(
            new CondiChildInfoVO("5万以上","hb004"),
            new CondiChildInfoVO("3万-5万","hb003"),
            new CondiChildInfoVO("1-3万","hb002"),
            new CondiChildInfoVO("无","hb001")
    ));

    public static CondiInfoVO baitao = new CondiInfoVO("京东白条", "baitao", Arrays.asList(
            new CondiChildInfoVO("5万以上","bt004"),
            new CondiChildInfoVO("3万-5万","bt003"),
            new CondiChildInfoVO("1-3万","bt002"),
            new CondiChildInfoVO("无","bt001")
    ));

    public static CondiInfoVO yuqi = new CondiInfoVO("逾期情况", "yuqi", Arrays.asList(
            new CondiChildInfoVO("无逾期","yq002")
    ));

    public static CondiInfoVO house = new CondiInfoVO("房产情况", "house", Arrays.asList(
            new CondiChildInfoVO("有房产","hu002")
    ));

    public static CondiInfoVO car = new CondiInfoVO("车产情况", "car", Arrays.asList(
            new CondiChildInfoVO("有车","car002")
    ));


    public static CondiInfoVO gjj = new CondiInfoVO("公积金", "gjj", Arrays.asList(
            new CondiChildInfoVO("有公积金","gjj002"),
            new CondiChildInfoVO("6个月以上","gjj003"),
            new CondiChildInfoVO("6个月以下","gjj004")
    ));

    public static CondiInfoVO enterpriseOwner = new CondiInfoVO("企业主", "enterpriseOwner", Arrays.asList(
            new CondiChildInfoVO("是企业主","eo002")
    ));

    /**
     *  xl001("无", "xl001"),
     *         xl002("中专及以下", "xl002"),
     *         xl003("大专", "xl003"),
     *         xl004("本科", "xl004"),
     *         xl005("研究生及以上", "xl005"),
     */
    public static CondiInfoVO xueli = new CondiInfoVO("学历", "xueli", Arrays.asList(
            new CondiChildInfoVO("研究生及以上","xl005"),
            new CondiChildInfoVO("本科","xl004"),
            new CondiChildInfoVO("大专","xl003"),
            new CondiChildInfoVO("中专及以下","xl002"),
            new CondiChildInfoVO("无","xl001")
    ));

    public static CondiInfoVO insurance = new CondiInfoVO("保单", "insurance", Arrays.asList(
//            new CondiChildInfoVO("无保单","in001"),
            new CondiChildInfoVO("有保单","in002"),
            new CondiChildInfoVO("2年以上","in003"),
            new CondiChildInfoVO("2年以下","in004")
    ));

    public static CondiInfoVO socialInsurance = new CondiInfoVO("社保", "socialInsurance", Arrays.asList(
//            new CondiChildInfoVO("无社保","si001"),
            new CondiChildInfoVO("有社保","si002"),
            new CondiChildInfoVO("6个月以上","si003"),
            new CondiChildInfoVO("6个月以下","si004")
    ));

    public static CondiInfoVO loanAmount = new CondiInfoVO("贷款金额", "loanAmount", Arrays.asList(
            new CondiChildInfoVO("1-3万","la001"),
            new CondiChildInfoVO("3-5万","la002"),
            new CondiChildInfoVO("5万-10万","la003"),
            new CondiChildInfoVO("10万-20万","la004"),
            new CondiChildInfoVO("20万以上","la005")
    ));

    public static CondiInfoVO orFilter = new CondiInfoVO("任选一", "orFilter", Arrays.asList(
            new CondiChildInfoVO("是企业主","eo002"),
            new CondiChildInfoVO("有房","hu002"),
            new CondiChildInfoVO("有车","car002"),
            new CondiChildInfoVO("有公积金","gjj002"),
            new CondiChildInfoVO("无逾期","yq002"),
            new CondiChildInfoVO("有社保","si002"),
            new CondiChildInfoVO("有保单","in002")
    ));

    static {

        dataList.add(notPush);
        dataList.add(loanAmount);
        dataList.add(zhima);
        dataList.add(baitao);
        dataList.add(huabei);
        dataList.add(xueli);
        dataList.add(yuqi);
        dataList.add(house);
        dataList.add(car);
        dataList.add(gjj);
        dataList.add(enterpriseOwner);
        dataList.add(insurance);
        dataList.add(socialInsurance);
        dataList.add(orFilter);

    }

    public static List<CondiInfoVO> getCheckdNotPushWeekDataList(List<CondiInfoVO> checkedDataList, String notPushWeek){
        List<String> valueList = StrUtil.isEmpty(notPushWeek)?new ArrayList<>():JSON.parseArray(notPushWeek, String.class);

        CondiInfoVO newNotPushWeek = new CondiInfoVO();
        BeanUtil.copyProperties(notPush, newNotPushWeek, "checked");

        newNotPushWeek.getChildInfoList().stream().forEach(condiChildInfoVO -> {
            if (CollUtil.isNotEmpty(valueList) && valueList.contains(condiChildInfoVO.getValue())){
                condiChildInfoVO.setChecked(true);
            }else{
                condiChildInfoVO.setChecked(false);
            }
        });

        checkedDataList.add(newNotPushWeek);
        return checkedDataList;
    }


    public static List<CondiInfoVO> getCheckdLoanAmountDataList(List<CondiInfoVO> checkedDataList, String loanAmountValue){
        List<String> valueList = StrUtil.isEmpty(loanAmountValue)?new ArrayList<>():JSON.parseArray(loanAmountValue, String.class);

        CondiInfoVO newLoanAmount = new CondiInfoVO();
        BeanUtil.copyProperties(loanAmount, newLoanAmount, "checked");

        newLoanAmount.getChildInfoList().stream().forEach(condiChildInfoVO -> {
            if (CollUtil.isNotEmpty(valueList) && valueList.contains(condiChildInfoVO.getValue())){
                condiChildInfoVO.setChecked(true);
            }else{
                condiChildInfoVO.setChecked(false);
            }
        });

        checkedDataList.add(newLoanAmount);
        return checkedDataList;
    }

    public static List<CondiInfoVO> getCheckdInsuranceDataList(List<CondiInfoVO> checkedDataList, String insuranceValue){
        List<String> valueList = StrUtil.isEmpty(insuranceValue)?new ArrayList<>():JSON.parseArray(insuranceValue, String.class);

        CondiInfoVO newInsurance = new CondiInfoVO();
        BeanUtil.copyProperties(insurance, newInsurance, "checked");

        newInsurance.getChildInfoList().stream().forEach(condiChildInfoVO -> {
            if (CollUtil.isNotEmpty(valueList) && valueList.contains(condiChildInfoVO.getValue())){
                condiChildInfoVO.setChecked(true);
            }else{
                condiChildInfoVO.setChecked(false);
            }
        });

        checkedDataList.add(newInsurance);
        return checkedDataList;
    }

    public static List<CondiInfoVO> getCheckdSocialInsuranceDataList(List<CondiInfoVO> checkedDataList, String socialInsuranceValue){
        List<String> valueList = StrUtil.isEmpty(socialInsuranceValue)?new ArrayList<>():JSON.parseArray(socialInsuranceValue, String.class);

        CondiInfoVO newSocialInsurance = new CondiInfoVO();
        BeanUtil.copyProperties(socialInsurance, newSocialInsurance, "checked");

        newSocialInsurance.getChildInfoList().stream().forEach(condiChildInfoVO -> {
            if (CollUtil.isNotEmpty(valueList) && valueList.contains(condiChildInfoVO.getValue())){
                condiChildInfoVO.setChecked(true);
            }else{
                condiChildInfoVO.setChecked(false);
            }
        });

        checkedDataList.add(newSocialInsurance);
        return checkedDataList;
    }

    public static List<CondiInfoVO> getCheckdXueLiDataList(List<CondiInfoVO> checkedDataList, String xueliValue){
        List<String> valueList = StrUtil.isEmpty(xueliValue)?new ArrayList<>():JSON.parseArray(xueliValue, String.class);

        CondiInfoVO newXueLi = new CondiInfoVO();
        BeanUtil.copyProperties(xueli, newXueLi, "checked");

        newXueLi.getChildInfoList().stream().forEach(condiChildInfoVO -> {
            if (CollUtil.isNotEmpty(valueList) && valueList.contains(condiChildInfoVO.getValue())){
                condiChildInfoVO.setChecked(true);
            }else{
                condiChildInfoVO.setChecked(false);
            }
        });

        checkedDataList.add(newXueLi);
        return checkedDataList;
    }

    public static List<CondiInfoVO> getCheckdEnterpriseOwnerDataList(List<CondiInfoVO> checkedDataList, String enterpriseOwnerValue){
        List<String> valueList = StrUtil.isEmpty(enterpriseOwnerValue)?new ArrayList<>():JSON.parseArray(enterpriseOwnerValue, String.class);

        CondiInfoVO newEnterpriseOwner = new CondiInfoVO();
        BeanUtil.copyProperties(enterpriseOwner, newEnterpriseOwner, "checked");

        newEnterpriseOwner.getChildInfoList().stream().forEach(condiChildInfoVO -> {
            if (CollUtil.isNotEmpty(valueList) && valueList.contains(condiChildInfoVO.getValue())){
                condiChildInfoVO.setChecked(true);
            }else{
                condiChildInfoVO.setChecked(false);
            }
        });

        checkedDataList.add(newEnterpriseOwner);
        return checkedDataList;
    }


    public static List<CondiInfoVO> getCheckdZhiMaDataList(List<CondiInfoVO> checkedDataList, String zhimaValue){
        List<String> valueList = StrUtil.isEmpty(zhimaValue)?new ArrayList<>():JSON.parseArray(zhimaValue, String.class);

        CondiInfoVO newZhima = new CondiInfoVO();
        BeanUtil.copyProperties(zhima, newZhima, "checked");

        newZhima.getChildInfoList().stream().forEach(condiChildInfoVO -> {
            if (CollUtil.isNotEmpty(valueList) && valueList.contains(condiChildInfoVO.getValue())){
                condiChildInfoVO.setChecked(true);
            }else{
                condiChildInfoVO.setChecked(false);
            }
        });

        checkedDataList.add(newZhima);
        return checkedDataList;
    }


    public static List<CondiInfoVO> getCheckdBaiTiaoDataList(List<CondiInfoVO> checkedDataList, String baitiaoValue){
        List<String> valueList = StrUtil.isEmpty(baitiaoValue)?new ArrayList<>():JSON.parseArray(baitiaoValue, String.class);

        CondiInfoVO newBaitiao = new CondiInfoVO();
        BeanUtil.copyProperties(baitao, newBaitiao, "checked");

        newBaitiao.getChildInfoList().stream().forEach(condiChildInfoVO -> {
            if (CollUtil.isNotEmpty(valueList) && valueList.contains(condiChildInfoVO.getValue())){
                condiChildInfoVO.setChecked(true);
            }else{
                condiChildInfoVO.setChecked(false);
            }
        });

        checkedDataList.add(newBaitiao);
        return checkedDataList;
    }

    public static List<CondiInfoVO> getCheckdHuaBeiDataList(List<CondiInfoVO> checkedDataList, String huabeiValue){
        List<String> valueList = StrUtil.isEmpty(huabeiValue)?new ArrayList<>():JSON.parseArray(huabeiValue, String.class);

        CondiInfoVO newHuabei = new CondiInfoVO();
        BeanUtil.copyProperties(huabei, newHuabei, "checked");

        newHuabei.getChildInfoList().stream().forEach(condiChildInfoVO -> {
            if (CollUtil.isNotEmpty(valueList) && valueList.contains(condiChildInfoVO.getValue())){
                condiChildInfoVO.setChecked(true);
            }else{
                condiChildInfoVO.setChecked(false);
            }
        });

        checkedDataList.add(newHuabei);
        return checkedDataList;
    }

    public static List<CondiInfoVO> getCheckdYuqiDataList(List<CondiInfoVO> checkedDataList, String yuqiValue){
        List<String> valueList = StrUtil.isEmpty(yuqiValue)?new ArrayList<>():JSON.parseArray(yuqiValue, String.class);

        CondiInfoVO newYuqi = new CondiInfoVO();
        BeanUtil.copyProperties(yuqi, newYuqi, "checked");

        newYuqi.getChildInfoList().stream().forEach(condiChildInfoVO -> {
            if (CollUtil.isNotEmpty(valueList) && valueList.contains(condiChildInfoVO.getValue())){
                condiChildInfoVO.setChecked(true);
            }else{
                condiChildInfoVO.setChecked(false);
            }
        });

        checkedDataList.add(newYuqi);
        return checkedDataList;
    }

    public static List<CondiInfoVO> getCheckdHouseDataList(List<CondiInfoVO> checkedDataList, String houseValue){
        List<String> valueList = StrUtil.isEmpty(houseValue)?new ArrayList<>():JSON.parseArray(houseValue, String.class);

        CondiInfoVO newHouse = new CondiInfoVO();
        BeanUtil.copyProperties(house, newHouse, "checked");

        newHouse.getChildInfoList().stream().forEach(condiChildInfoVO -> {
            if (CollUtil.isNotEmpty(valueList) && valueList.contains(condiChildInfoVO.getValue())){
                condiChildInfoVO.setChecked(true);
            }else{
                condiChildInfoVO.setChecked(false);
            }
        });

        checkedDataList.add(newHouse);
        return checkedDataList;
    }

    public static List<CondiInfoVO> getCheckdCarDataList(List<CondiInfoVO> checkedDataList, String carValue){
        List<String> valueList = StrUtil.isEmpty(carValue)?new ArrayList<>():JSON.parseArray(carValue, String.class);

        CondiInfoVO newCar = new CondiInfoVO();
        BeanUtil.copyProperties(car, newCar, "checked");

        newCar.getChildInfoList().stream().forEach(condiChildInfoVO -> {
            if (CollUtil.isNotEmpty(valueList) && valueList.contains(condiChildInfoVO.getValue())){
                condiChildInfoVO.setChecked(true);
            }else{
                condiChildInfoVO.setChecked(false);
            }
        });

        checkedDataList.add(newCar);
        return checkedDataList;
    }

    public static List<CondiInfoVO> getCheckdGjjDataList(List<CondiInfoVO> checkedDataList, String gjjValue){
        List<String> valueList = StrUtil.isEmpty(gjjValue)?new ArrayList<>():JSON.parseArray(gjjValue, String.class);

        CondiInfoVO newGjj = new CondiInfoVO();
        BeanUtil.copyProperties(gjj, newGjj, "checked");

        newGjj.getChildInfoList().stream().forEach(condiChildInfoVO -> {
            if (CollUtil.isNotEmpty(valueList) && valueList.contains(condiChildInfoVO.getValue())){
                condiChildInfoVO.setChecked(true);
            }else{
                condiChildInfoVO.setChecked(false);
            }
        });

        checkedDataList.add(newGjj);
        return checkedDataList;
    }

    public static List<CondiInfoVO> getCheckdOrFilterDataList(List<CondiInfoVO> checkedDataList, String orfilterValue){
        List<String> valueList = StrUtil.isEmpty(orfilterValue)?new ArrayList<>():JSON.parseArray(orfilterValue, String.class);

        CondiInfoVO newOrFilter = new CondiInfoVO();
        BeanUtil.copyProperties(orFilter, newOrFilter, "checked");

        newOrFilter.getChildInfoList().stream().forEach(condiChildInfoVO -> {
            if (CollUtil.isNotEmpty(valueList) && valueList.contains(condiChildInfoVO.getValue())){
                condiChildInfoVO.setChecked(true);
            }else{
                condiChildInfoVO.setChecked(false);
            }
        });

        checkedDataList.add(newOrFilter);
        return checkedDataList;
    }
}
